home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Erics C++ Libraries / Interface Classes / CPPWindowManager.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  3.3 KB  |  122 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/21/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPWindowManager
  6.     
  7.     SUPERCLASS: CPPObject
  8.     
  9.         This C++ class keeps track of the windows our application uses
  10.     
  11. ********************************************************************/
  12.  
  13. #pragma once
  14.  
  15. #include <CPPWindowManager.h>
  16. #include <CPPWindow.h>
  17.  
  18.  
  19. /*-----------------------------------------------------------------*/
  20. /*------------------------ PUBLIC METHODS -------------------------*/
  21. /*-----------------------------------------------------------------*/
  22.  
  23.     CPPWindowManager::CPPWindowManager(void) : CPPObjectList ()
  24.     {
  25.         this->frontWindowObject = NULL;
  26.     }
  27.             
  28. /*-----------------------------------------------------------------*/
  29.  
  30.     CPPWindowManager::~CPPWindowManager(void)
  31.     {
  32.         // Repeatedly dispose of the frontmost window
  33.         // until all the windows we manage are gone
  34.         for (long i = GetNumItems(); i > 0; i--)
  35.           CPPList::DeleteItem (1, TRUE);
  36.     }
  37.                     
  38. /*-----------------------------------------------------------------*/
  39.  
  40.     char    *CPPWindowManager::ClassName (void)
  41.     {
  42.         return "CPPWindowManager";
  43.     }
  44.     
  45. /*-----------------------------------------------------------------*/
  46.  
  47.     void    CPPWindowManager::DeactivateWindowObject (CPPWindow *theWindow)
  48.     /* deactivate the window object which is passed to us, and activate */
  49.     /* the new front window object (if there is a different one) */
  50.     {
  51.         CPPWindow    *newFW = NULL;
  52.         
  53.         if (theWindow)
  54.           {
  55.               theWindow->Deactivate();
  56.             this->frontWindowObject = NULL;
  57.           }
  58.     }
  59.  
  60. /*-----------------------------------------------------------------*/
  61.  
  62.     void    CPPWindowManager::ActivateWindowObject (CPPWindow *theWindow)
  63.     /* deactivate the current front window object and activate the one */
  64.     /* which is passed to us */
  65.     {
  66.         if (theWindow)
  67.           {
  68.               if (this->frontWindowObject)
  69.                 this->frontWindowObject->Deactivate();
  70.             theWindow->Activate();
  71.             this->frontWindowObject = theWindow;
  72.           }
  73.     }
  74.  
  75. /*-----------------------------------------------------------------*/
  76.  
  77.     CPPWindow    *CPPWindowManager::FrontWindowObject (void)
  78.     /* return the CPPWindow object associated with the front window */
  79.     {
  80.         return FindWindowObject (FrontWindow());
  81.     }
  82.  
  83. /*-----------------------------------------------------------------*/
  84.  
  85.     CPPWindow    *CPPWindowManager::FindWindowObject (WindowPtr theWindow)
  86.     /* return the CPPWindow object associated with theWindow */
  87.     {
  88.         long numItems = this->GetNumItems();
  89.         CPPWindow        *TempWindow;
  90.         
  91.         for (long i = 1;i <= numItems; i++)
  92.           {
  93.               TempWindow = (CPPWindow *)((*this)[i]);
  94.               if (TempWindow)
  95.                 if (TempWindow->GetWindow() == theWindow)
  96.                   return TempWindow;
  97.           }
  98.           
  99.         return NULL;
  100.     }
  101.     
  102. /*-----------------------------------------------------------------*/
  103.  
  104.     void CPPWindowManager::StartManagingWindow (CPPWindow *theWindow)
  105.     /* add this window object to the list of window objects we manage */
  106.     {
  107.         if (theWindow)
  108.           this->AppendItem(theWindow);
  109.     }
  110.  
  111. /*-----------------------------------------------------------------*/
  112.  
  113.     void CPPWindowManager::StopManagingWindow (CPPWindow *theWindow)
  114.     /* Remove the window object from the list of object we manage */
  115.     {
  116.         DeleteItem (theWindow, FALSE);
  117.         if (this->frontWindowObject == theWindow)
  118.           this->frontWindowObject = NULL;
  119.     }
  120.  
  121. /*-----------------------------------------------------------------*/
  122.